package pack;


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import util.Logger;

import model.WorldController;



public final class Engine {
    public static final int SPAWN_X;
    public static final int SPAWN_Y;
    public static final int DEFAULT_HEAD_ID;
    public static final int DEFAULT_TORSO_ID;
    public static final int DEFAULT_LEGS_ID;
    private static ThreadGroup threadGroup = new ThreadGroup("Scape");

    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        WorldController.loadMap();
        new World(1, "0.0.0.0");
    }

    public static void newThread(Runnable r) {
        Thread t = new Thread(threadGroup, r);
        t.setPriority(Thread.MAX_PRIORITY);
        t.start();
    }

    static {
        Properties config = new Properties();
        try {
            config.load(new FileInputStream("./server_files/config.ini"));
        } catch (FileNotFoundException fnfe) {
            Logger.println("Please configure server_files/config.ini before running the server");
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        SPAWN_X = Integer.parseInt(config.getProperty("spawnx"));
        SPAWN_Y = Integer.parseInt(config.getProperty("spawny"));
        DEFAULT_HEAD_ID = Integer.parseInt(config.getProperty("headid"));
        DEFAULT_TORSO_ID = Integer.parseInt(config.getProperty("torsoid"));
        DEFAULT_LEGS_ID = Integer.parseInt(config.getProperty("legsid"));
    }
}